package com.demo.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.demo.dao.Result;
import com.demo.pojo.system.LoginLog;
import com.demo.service.system.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/loginLog")
public class LoginLogController {
    @Autowired
    private LoginLogService loginLogService;

    @GetMapping
    public Result<Page<LoginLog>> getLoginLog(int pageNum, int pageSize,
                                              @RequestParam(required = false,defaultValue = "") String username) {
        Page<LoginLog> page = loginLogService.lambdaQuery()
                .like(LoginLog::getUsername, username)
                .page(Page.of(pageNum, pageSize));
        return Result.success(page);
    }
}
